<%@page import="com.bringway.global.util.UserUtil"%>
<%@page import="com.bringway.global.constant.P2pConstant"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String baseUrl = request.getContextPath();
	request.setAttribute("baseUrl", baseUrl);
	if(null !=  UserUtil.getCurrentUser()){
		response.sendRedirect(baseUrl + "/pages/main/main.jsp");		
	}
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>登陆</title>

<style>
*{
	padding:0px;
	margin:0px;
	}

body{/CHDSJ/WebContent/global/images/login
	font-family:Arial, Helvetica, sans-serif;
	background:url(global/images/login/grass.jpg);
	font-size:13px;
    background-repeat:no-repeat;
	}
img{
	border:0;
	}
.lg{width:468px; height:468px; margin:100px auto; background:url(global/images/login/login_bg.jpg) no-repeat;}
.lg_top{ height:200px; width:468px;}
.lg_main{width:400px; height:180px; margin:0 25px;}
.lg_m_1{
	width:290px;
	height:100px;
	padding:60px 55px 20px 55px;
}
.ur{
	height:37px;
	border:0;
	color:#666;
	width:236px;
	margin:4px 28px;
	background:url(global/images/login/user.jpg) no-repeat;
	padding-left:10px;
	font-size:16pt;
	font-family:Arial, Helvetica, sans-serif;
}
.pw{
	height:37px;
	border:0;
	color:#666;
	width:236px;
	margin:4px 28px;
	background:url(global/images/login/password.jpg) no-repeat;
	padding-left:10px;
	font-size:16pt;
	font-family:Arial, Helvetica, sans-serif;
}
.bn{
    width:330px; 
	height:72px; 
	background:url(global/images/login/enter.png) no-repeat; 
	border:0; 
	display:block;
	font-size:18px; 
	color:#FFF; 
	font-family:Arial, Helvetica, sans-serif;
	font-weight:bolder;
  }
.lg_foot{
	height:80px;
	width:330px;
	padding: 6px 68px 0 68px;
}
.diu{
	position: absolute;
	top: 92%;
	left: 40%;
	font-size: 16px;
	
}
</style>
<script type="text/javascript" src="global/Plug/jquery/jquery.js"></script>
<script type="text/javascript" src="global/Plug/jquery/script.js"></script>
<script type="text/javascript">
	var baseUrl = '<%=baseUrl%>';
	$(document).keydown(function(e) {
		if (e.keyCode == 13) {
			submitTest();
		}
	});

	function submitTest() {
		var j_username = $("#j_username").val();
		var j_password = $("#j_password").val();

		if (j_username == '') {
			$("#error1").html("工号不能为空！");
			return false;
		} else {
			$("#error1").html("");
		}
		if (j_password == '') {
			$("#error2").html("密码不能为空！");
			return false;
		} else {
			$("#error2").html("");
		}
		if (!j_username == '' && !j_password == '') {
			var ckh_result = false;
			var params = $("#new_user_session").serialize();
			console.log(params);
			$.post(baseUrl + "/p2puser/p2pLogin.do", {
				j_username : j_username,
				j_password : j_password
			}, function(data, status) {
				if (data.data.msg == "登陆成功！") {
					document.form.submit();
					ckh_result = true;
				} else {
					if (data.data.msg == "用户名输入错误！") {
						$("#error1").html("请输入正确的工号！");
						ckh_result = false;
					}
					if (data.data.msg == "密码错误！") {
						$("#error2 ").html("请输入正确的密码！");
						ckh_result = false;
					} else {
						ckh_result = false;
					}
				}
			}, "json");
			return ckh_result;
		}
	}
</script>
</head>

<body class="b">
<div class="lg">
<form id="new_user_session" name="form"action="<%=baseUrl%>/j_spring_security_check"
			onSubmit="return submitTest();" novalidate="novalidate"
			class="simple_form user" accept-charset="UTF-8" data-remote="true"
			method="post">
    <div class="lg_top"></div>
    <div class="lg_main">
        <div class="lg_m_1">
	        <input type="text" name="j_username" id="j_username" class="ur" />
	        <p class="error" id="error1"></p>
	        <input  type="password"  name="j_password" id="j_password" class="pw"/>
	        <p class="error" id="error2"></p>
        </div>
    </div>
    <div class="lg_foot">
    <input type="submit" value="登陆" id="loginBtn" class="bn" /></div>
</form>
</div>
<div class="diu">
		<br /> Copyright © 2016 <%=P2pConstant.CopyrightCompanyName%> 服务电话：<%=P2pConstant.CompanyPhone %>
	</div>
</body>
</html>
